<?php
/*
 * @Author: CHINAKAIYUAN<sunkaiyuan@namenode.cn>
 * @Date: 2022-02-03 00:33:05
 * @LastEditTime: 2022-08-25 21:33:51
 * @LastEditors: CHINAKAIYUAN
 * @Description: 面布 
 */

namespace App\Models;

use App\Traits\StorageTrait;

class OpenCardShellFabric extends BaseModel
    {
    use StorageTrait;
    public $timestamps = true;
    public $table = "sys_open_card_shell_fabric";
    protected $guarded = [];

    public function open_card()
        {
        return $this->belongsTo(OpenCard::class, "open_card_code", "code");
        }

    public function card_unit()
        {
        return $this->belongsTo(Dic::class, "card_unit_id", "key")->where(function ($q)
            {
            $q->where("code", 'unit');
            });
        }
    public function getPaperCode()
        {
        return $this->open_card->code;
        }

    public function status()
        {
        return $this->belongsTo(Dic::class, "status_id", "key")->where(function ($q)
            {
            $q->where("code", 'storagestatus_name');
            });
        }
    }
